<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      * {
        margin: 0;
        padding: 0;
      }
      html,
      body {
        height: 100%;
      }
      body {
        perspective: 1200px;
      }
      section {
        width: 300px;
        height: 100px;
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        right: 0;
        margin: auto;
        border: 1px solid #000;
        transform-style: preserve-3d;
        /* transform: rotateX(20deg) rotateY(30deg); */
        transform-origin: 50% 50% -50px;
        transition: 1s;
      }
      div {
        position: absolute;
        width: 100%;
        height: 100%;
        top: 0;
        left: 0;
        color: #fff;
        font-size: 40px;
      }
      div:first-child {
        background-color: lightcoral;
      }
      div:last-child {
        background-color: lightblue;
        transform: translateY(100px) rotateX(-90deg);
        transform-origin: 0% 0%;
      }
      section:hover {
        transform: rotateX(90deg);
      }
    </style>
  </head>
  <body>
    <section>
      <div>1</div>
      <div>2</div>
    </section>
  </body>
</html>
